package Vistas;
import java.util.Vector;
import javax.swing.JScrollPane;

import javax.swing.JTable;

import javax.swing.WindowConstants;
import javax.swing.table.DefaultTableModel;
import Modelos.Ingrediente;
import Modelos.IngredienteProducto;
import Modelos.Producto;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class FrmReportIngrediente extends javax.swing.JFrame {
	private JTable jTable1;
	private DefaultTableModel jTable1Model;

	/**
	* Auto-generated main method to display this JFrame
	*/
	
	
	public FrmReportIngrediente() {
		super();
		initGUI();
	}
	
	public void AgregarFila(Vector<Ingrediente> arringrediente,Vector<Producto> arrproducto,Vector<IngredienteProducto> arringredienteproducto,boolean descendente){

		
		

		if(descendente){
			for(int i=0;i<arringrediente.size();i++){
				Vector columna = new Vector();
				columna.add(arringrediente.elementAt(i).getNombre());
				for(int j=0;j<arringredienteproducto.size();j++){
					if(arringredienteproducto.elementAt(j).getCodingrediente()==arringrediente.elementAt(i).getCodigo()){
						for(int h=0;h<arrproducto.size();h++){
							if(arrproducto.elementAt(h).getCodigo()==arringredienteproducto.elementAt(j).getCodproducto()){
								columna.add(arrproducto.elementAt(h).getNombre());
								jTable1Model.addRow(columna);
								System.out.println("agregue");
							}
						}
					}
				}
			}
		}
		else
		{
			for(int i=arringrediente.size()-1;i>=0;i--){
				JScrollPane jScrollPane1;
				Vector columna = new Vector();
				columna.add(arringrediente.elementAt(i).getNombre());
				for(int j=0;j<arringredienteproducto.size();j++){
					if(arringredienteproducto.elementAt(j).getCodingrediente()==arringrediente.elementAt(i).getCodigo()){
						for(int h=0;h<arrproducto.size();h++){
							if(arrproducto.elementAt(h).getCodigo()==arringredienteproducto.elementAt(j).getCodproducto()){
								columna.add(arrproducto.elementAt(h).getNombre());
								jTable1Model.addRow(columna);
								System.out.println("agregue");
							}
						}
					}
				}
			}
		}
		
		
	}
	
	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			getContentPane().setLayout(null);
			{
				JScrollPane jScrollPane1 = new JScrollPane();
				getContentPane().add(jScrollPane1);
				jScrollPane1.setBounds(48, 56, 627, 277);
				{
					jTable1Model = new DefaultTableModel(0,2);
					/*new DefaultTableModel(
							new String[][] { { "One", "Two" }, { "Three", "Four" } },
							new String[] { "Column 1", "Column 2" });*/
							jTable1 = new JTable();
							jScrollPane1.setViewportView(jTable1);

							jTable1.setModel(jTable1Model);
							jTable1.setBounds(482, 56, 249, 196);
				}
			}
			pack();
			this.setSize(718, 383);
		} catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
	}

}
